/*文件上传*/
function skyUpload(upid,url,success,error,uploadProgress)
{
		 var vFD = new FormData();
		 var f= document.getElementById(upid).files;
		 $("#"+upid+"loading").show();
		 for(var i=0;i<f.length;i++){ 
		vFD.append('upimg', document.getElementById(upid).files[i]);
		// create XMLHttpRequest object, adding few event listeners, and POSTing our data
		var oXHR = new XMLHttpRequest();        
		oXHR.addEventListener('load', success, false);
		oXHR.addEventListener('error', error, false);
		if(uploadProgress!=undefined){
			oXHR.upload.addEventListener("progress", uploadProgress, false);
		}
		oXHR.open('POST',url);
		oXHR.send(vFD);
	
		 }
}
/*
function uploadFinish(e){
		var data=eval("("+e.target.responseText+")");
		$("#uploading").hide()
		if(data.error != '')
        {
           skyToast(data.msg);
        }else
        {
            $("#imgShow").html("<img src='/"+data.imgurl+".100x100.jpg' width='100'>");
			$("#imgurl").val(data.imgurl);
         }
}
	
function uploadError(e) { // upload error
		skyToast("上传出错了");
}
*/

function err_user_head(obj,t){
	//event.preventDefault();
	if(t==1){
		obj.src="/static/images/user_head.jpg.small.jpg";
	}else{
		obj.src="/static/images/user_head.jpg.100x100.jpg";
	}
	
}
function err_imgurl(obj,t){
	//event.preventDefault();
	if(t==1){
		obj.src="/static/images/no_image.jpg.small.jpg";
	}else if(t==2){
		obj.src="/static/images/no_image.jpg.middle.jpg";
	}else{
		obj.src="/static/images/no_image.jpg.100x100.jpg";
	}
}
/*弹框*/
function showbox(title,content,width,height){
	if($("#showbox_container").length==0){
		var html='<div id="showBox_opac" ></div><div id="showBox" onDblClick="showboxClose()" style=" width:100%; height:100%;  "><div id="showbox_container"><div id="showBox_nav"><div id="showBox_title">  </div><div id="showBox_close" onclick="showboxClose()">关闭</a></div></div><div id="showBox_content"></div><div id="showBox_footer"></div></div></div>'; 
		$("body").append(html); 
	}
	$("#showBox_title").html(title);
	$("#showBox_content").html(content);
	$("#showBox").show();
	$("#showBox_opac").show();
	var mt= Math.max(10,( window.innerHeight-parseInt(height))/2);
	$("#showbox_container").css({width:width-10,minHeight:height,marginTop:mt});
	setTimeout(function(){
		width=$("#showbox_container").css("width");
		height=$("#showbox_container").css("height");
		height=parseInt(height);
		width=parseInt(width);
		var mt= Math.max(10,( window.innerHeight-parseInt(height))/2);
		$("#showbox_container").css({width:width-10,minHeight:height,marginTop:mt});
	},60);
	 
}

function showboxClose(){
	$("#showBox_opac").hide();
	$("#showBox_content").html("");
	$("#showBox").css("display","none");
}
function goBack(){
	window.history.back();
}
$(function(){
	$(document).on("click",".goBack",function(){
		window.history.back();
		var href=$(this).attr("href");
		if(href=="" || href==undefined){
			href="/index.php";
		}
		setTimeout(function(){
			window.location=href;
		},600);
		
	});
	
	$(document).on("click",".js-delete",function(){
		var obj=$(this); 
		var url=$(this).attr("url");
		if(confirm("确认删除吗?")){
			$.get(url,function(data){
				mui.toast(data.message);
				obj.parents(".item").remove();
			},"json")
		}
		
	})
	
});
